//开启一次性定时器，3秒以后创建1~10,10个目录；15秒以后再把这10个目录删除

const fs = require("fs");
const path = require("path");

setTimeout(() => {
    console.log("创建目录");
    for (let i = 0; i < 10; i++) {
        let dirPath = path.resolve(__dirname, String(i + 1));
        console.log(`创建目录${dirPath}`);
        fs.mkdir(dirPath, (err) => {
            if (err) {
                console.log(err);
            }
        });
    }
}, 3000);

setTimeout(() => {
    console.log("删除目录");
    for (let i = 0; i < 10; i++) {
        let dirPath = path.resolve(__dirname, String(i + 1));
        console.log(`删除目录${dirPath}`);
        fs.rmdir(dirPath, { recursive: true }, (err) => {
            if (err) {
                console.log(err);
            }
        });
    }
}, 15000);
